﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Data.SqlClient;

namespace QUAN_LY_MUON_TRA_SACH
{
    public partial class rpt_the_doc_gia : DevExpress.XtraReports.UI.XtraReport
    {
        public rpt_the_doc_gia()
        {
            InitializeComponent();
        }
        public static string mathe = null;
        public void BindData()
        {
            SqlCommand lenh = new SqlCommand("select upper(hten_dg) from the_doc_gia where mathe='"+mathe+"'",Connection.sqlConnection);
            xlbhoten.Text = Convert.ToString(lenh.ExecuteScalar());
            xlbho_ten.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select mathe from the_doc_gia where mathe='" + mathe + "'", Connection.sqlConnection);
            xlbmathe.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select upper(dgiai) from the_doc_gia a,loai_doc_gia b where a.ma_loai_dgia=b.ma_loai_dgia and mathe='" + mathe + "'", Connection.sqlConnection);
            xlbloaidg.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select RTRIM(CAST((DATEPART(DAY,ngsinh_dg)) AS CHAR(5)))+'/'+RTRIM(CAST((DATEPART(MONTH,ngsinh_dg)) AS CHAR(5)))+'/'+CAST((DATEPART(YEAR,ngsinh_dg)) AS CHAR(5)) from the_doc_gia where mathe='" + mathe + "'", Connection.sqlConnection);
            xlbngaysinh.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select cmnd from the_doc_gia where mathe='" + mathe + "'", Connection.sqlConnection);
            xlbcmnd.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select diachi from the_doc_gia where mathe='" + mathe + "'", Connection.sqlConnection);
            xlbdiachi.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select ten_ng from the_doc_gia a, nganh b where a.ma_ng=b.ma_ng and mathe='" + mathe + "'", Connection.sqlConnection);
            xlbnganhhoc.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select N'KHOA '+upper(tenkhoa) from the_doc_gia a, nganh b,khoa c where a.ma_ng=b.ma_ng and b.makhoa=c.makhoa and mathe='" + mathe + "'", Connection.sqlConnection);
            xlbkhoa.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select N'TRƯỜNG '+upper(ten_trg) from the_doc_gia a, nganh b,khoa c,truong d where a.ma_ng=b.ma_ng and b.makhoa=c.makhoa and c.ma_trg=d.ma_trg and mathe='" + mathe + "'", Connection.sqlConnection);
            xlbtruong.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select PATH_ANH_DOC_GIA from the_doc_gia where mathe='" + mathe + "'", Connection.sqlConnection);
            if (Convert.ToString(lenh.ExecuteScalar()) != "")
                xptanhdocgia.ImageUrl = Convert.ToString(lenh.ExecuteScalar());
        }
    }
}
